$(function () {
    /*供货商所有单据*/
    $('#firstDate').datetimepicker({
        //viewMode: 'day',
        format: 'YYYY-MM-DD'
    });
    $('#secondDate').datetimepicker({
        format: 'YYYY-MM-DD',
        useCurrent: false //Important! See issue #1075
    });
    $("#firstDate").on("dp.change", function (e) {
        $('#secondDate').data("DateTimePicker").minDate(e.date);
    });
    $("#secondDate").on("dp.change", function (e) {
        $('#firstDate').data("DateTimePicker").maxDate(e.date);
    });

    /*供货商供货情况*/
    $('#firstDate1').datetimepicker({
        //viewMode: 'day',
        format: 'YYYY-MM-DD'
    });
    $('#secondDate1').datetimepicker({
        format: 'YYYY-MM-DD',
        useCurrent: false //Important! See issue #1075
    });
    $("#firstDate1").on("dp.change", function (e) {
        $('#secondDate1').data("DateTimePicker").minDate(e.date);
    });
    $("#secondDate1").on("dp.change", function (e) {
        $('#firstDate1').data("DateTimePicker").maxDate(e.date);
    });
    /*明细表*/

    $('#firstDate2').datetimepicker({
        //viewMode: 'day',
        format: 'YYYY-MM-DD'
    });
    $('#secondDate2').datetimepicker({
        format: 'YYYY-MM-DD',
        useCurrent: false //Important! See issue #1075
    });
    $("#firstDate2").on("dp.change", function (e) {
        $('#secondDate2').data("DateTimePicker").minDate(e.date);
    });
    $("#secondDate2").on("dp.change", function (e) {
        $('#firstDate2').data("DateTimePicker").maxDate(e.date);
    });







    $('#table').bootstrapTable({
    url: '${pageContext.request.contextPath}/../../j/Qqueryxianshi',
    columns: [

        {
            field: 'order',
            title: '订单号'
        }, {
            field: 'supplier.name',
            title: '供货商名称'
        },{
            field: 'date',
            title: '订单时间'
        },  {
            field: 'ietype.type',
            title: '类型'
        },  {
            field: 'money',
            title: '金额'
        },{
            field: 'staff.name',
            title: '经办人'
        }],

    /*method:'post',*/


    queryParamsType:'',
    detailView:true,
    queryParams: ss,


    height:500,
    pageList:[5,10,15],
    pageNumber:1,
    pageSize:5,
    pagination:true,
    sidePagination:'server',



    //当点击详细图标展开详细页面的时候触发。
    onExpandRow: function (index, row, $detail) {
        var table = $detail.html("<table></table>").find("table") ;
        table.bootstrapTable({
            url: '${pageContext.request.contextPath}/../../Qbb/QqueryByOrder?order1='+row.order+'',
            columns: [{
                field: 'number',
                title: '货品编号'
            },{
                field: 'name',
                title: '货品名称'
            },{
                field: 'comptype.name',
                title: '单位'
            },{
                field: 'money',
                title: '单价'
            },{
                field: 'num',
                title: '数量'
            },{
                field: 'specid',
                title: '规格'
            },{
                field: 'colortype.name',
                title: '颜色'
            },
            {
                field:'xx',
                title:'总金额',
                formatter: function (value, row, index) {
                    var jia = row.money * row.num;

                    return jia;
                }
            }],



        }) ;
    }

    });









    $('#syso').bootstrapTable({
        url: '${pageContext.request.contextPath}/../../Qbb/Qquer',
        columns: [{
            field: 'number',
            title: '货品编号'
        },{
            field: 'name',
            title: '货品名称'
        },{
            field: 'comptype.name',
            title: '单位'
        },{
            field: 'money',
            title: '单价'
        },{
            field: 'num',
            title: '数量'
        },{
            field: 'specid',
            title: '规格'
        },{
            field: 'colortype.name',
            title: '颜色'
        },{
            field: 'date',
            title: '时间'
        },{
            field:'xx',
            title:'总金额',
            formatter: function (value, row, index) {
                var jia = row.money * row.num;

                return jia;
            }
        }],




        //method:'post',
        contentType:"application/x-www-form-urlencoded",

         queryParamsType:'',
         // detailView:true,


        queryParams: maven,
        height:500,
        pageList:[5,10,15],
        pageNumber:1,
        pageSize:5,
        pagination:true,
        sidePagination:'server',
    });

    /*明细表*/
    $('#mingxibiao').bootstrapTable({
        url: '${pageContext.request.contextPath}/../../Qbb/Qminxi',
        columns: [{
            field: 'number',
            title: '货品编号'
        },{
            field: 'name',
            title: '货品名称'
        },{
            field: 'comptype.name',
            title: '单位'
        },{
            field: 'money',
            title: '单价'
        },{
            field: 'num',
            title: '数量'
        },{
            field: 'specid',
            title: '规格'
        },{
            field:'commtype.name',
            title:'商品类别'
        },{
            field: 'colortype.name',
            title: '颜色'
        },{
            field: 'supplier.name',
            title: '供货商名称'
        },{
            field:'xx',
            title:'总金额',
            formatter: function (value, row, index) {
                var jia = row.money * row.num;

                return jia;
            }
        }],

        contentType : "application/x-www-form-urlencoded",

        queryParamsType:'',

        queryParams: sss,


        height:500,
        pageList:[5,10,15],
        pageNumber:1,
        pageSize:5,
        pagination:true,
        sidePagination:'server',
    });


    /*进货分类明细表*/
    $('#jhfl').bootstrapTable({
        url: '${pageContext.request.contextPath}/../../Qbb/Qduoshao',
        columns: [{
            field: 'name',
            title: '类别名称'
        },{
            field: 'typeid',
            title: '进货数量'
        }],

    });

}) ;













/*供货商所有单据*/
function ban(){
    var opt = $("#table").bootstrapTable('getOptions') ;
    var firstDate = $("#firstDate").val() ;
    var secondDate = $("#secondDate").val() ;
    var supplierr = $('#supplierr').combogrid('getValue');



    $.post('${pageContext.request.contextPath}/../../j/Qqueryxianshi',{'supplierr':supplierr,'pageNumber':1,'pageSize':opt.pageSize,'firstDate':firstDate,'secondDate':secondDate},function(data){
        //重新给table绑定数据5
        $("#table").bootstrapTable("load",data) ;
    }) ;

}


function ss(params) {
    var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
        'pageSize': params.pageSize,  //页面大小
        'pageNumber': params.pageNumber, //页码
        'firstDate':$("#firstDate").val(),
        'secondDate':$("#secondDate").val(),
        'supplierr':$('#supplierr').combogrid('getValue'),
    };
    return temp;
};


/*供货商供货情况*/
function tome(){
    var opt = $("#syso").bootstrapTable('getOptions') ;
    var firstDate1 = $("#firstDate1").val() ;
    var secondDate1 = $("#secondDate1").val() ;
    var supplierid = $('#t').combogrid('getValue');

    $.post('${pageContext.request.contextPath}/../../Qbb/Qquer',{'supplierid':supplierid,'pageNumber':1,'pageSize':opt.pageSize,'firstDate1':firstDate1,'secondDate1':secondDate1},function(data){
        //重新给table绑定数据
        $("#syso").bootstrapTable("load",data) ;
    }) ;
    
}

function maven(params) {
    var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
        'pageSize': params.pageSize,  //页面大小
        'pageNumber': params.pageNumber, //页码
        'firstDate1':$("#firstDate1").val(),
        'secondDate1':$("#secondDate1").val(),
        'supplierid':$('#t').combogrid('getValue'),
    };
    return temp;
};
/*明细表*/
function mixxb() {

    var opt = $("#mingxibiao").bootstrapTable('getOptions');

    var firstDate1 = $("#firstDate2").val() ;
    var secondDate1 = $("#secondDate2").val();
    var typeid = $('#yiers').combogrid('getValue');
    var supplierid=$('#erees').combogrid('getValue');

    var name=$('#minzi').val();
    $.post('${pageContext.request.contextPath}/../../Qbb/Qminxi',{'supplierid':supplierid,'name':name,'typeid':typeid,'pageNumber':1,'pageSize':opt.pageSize,'firstDate1':firstDate1,'secondDate1':secondDate1},function(data){
        //重新给table绑定数据
        $("#mingxibiao").bootstrapTable("load",data) ;
    }) ;
}
function sss(params) {
    var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
        'pageSize': params.pageSize,  //页面大小
        'pageNumber': params.pageNumber, //页码
        'firstDate1':$("#firstDate2").val(),
        'secondDate1':$("#secondDate2").val(),
        'typeid':$('#yiers').combogrid('getValue'),
        'name':$('#minzi').val(),

        'supplierid':$('#erees').combogrid('getValue'),
    };
    return temp;
};


/*货品分类统计表*/
function supp() {
    var supplierid = $('#tt').combogrid('getValue');

    $.post('${pageContext.request.contextPath}/../../Qbb/Qduoshao',{'supplierid':supplierid},function(data){
        //重新给table绑定数据
        $("#jhfl").bootstrapTable("load",data) ;
    });

}








